ver = debug

ifeq ($(ver), debug)
CFLAGS += -Ddebug -g
else
CFLAGS += -O2
endif

ifeq ($(shell uname -s), Darwin)
CC = clang
else
CC = gcc
CFLAGS += -pthread
endif

SRC = src
BIN = bin
OBJ = obj
OBJ_C = ${OBJ}/ftp_client.o ${OBJ}/header.o ${OBJ}/network.o
OBJ_S = ${OBJ}/ftp_server.o ${OBJ}/header.o ${OBJ}/network.o
EXE_C = ${BIN}/ftp_client.out
EXE_S = ${BIN}/ftp_server.out


all:	clean client server

client:	${OBJ_C}
	${CC} ${CFLAGS} $^ -o ${EXE_C}

server:	${OBJ_S}
	${CC} ${CFLAGS} $^ -o ${EXE_S}

${OBJ}/%.o:	${SRC}/%.c
	${CC} ${CFLAGS} -c $< -o $@

clean:
	rm -f ${OBJ}/*.o
	rm -f ${BIN}/*.out
